
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWidget>
#include <QTimer>
#include "map.h"
#include "myplane.h"
#include "bullet.h"
#include "enemy.h"
#include "weapon.h"
#include <QSoundEffect>
#include <QLabel>
#include <QMediaPlayer>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow

{
    Q_OBJECT

public:
    QWidget *Myplane;
    QTimer winTimer;
    int flag=1;
    int flagw=1;
    bool hurtable=1;
    QTimer hurtTimer;
    MainWindow(QWidget *parent = nullptr);

    ~MainWindow();
   //初始化场景
    void initScene();
    //启动游戏
    void initMusic();
    //
    void playGame();
    //更新元素坐标
    void updatePosition();
    //绘制
    void paintEvent(QPaintEvent *);

    void mouseMoveEvent(QMouseEvent *);

    //void keyPressEvent(QKeyEvent *);

    void enemystart();

    void weaponstart();

    weapon m_weapons[WEAPON_NUM];

    enemy m_enemys[ENEMY_NUM];

    myplane m_planes;

    int m_recorder;

    //碰撞检测敌机与子弹
    void collision_e_b();
    //碰撞我机与军火
    void collision_m_w1();

    void collision_m_w2();
    //碰撞我机与敌机

    void collision_m_e1();
     void collision_m_e2();
      void collision_m_e3();
     void collision_m_e47();
      void defeat();
    //地图对象
    map m_map;

    //真我飞机
    myplane m_host;

    //定时器
    QTimer m_Timer;

    //子弹
    bullet temp_bullet;

    QLabel mHp;

    QLabel koe;

    QMediaPlayer music;

public slots:
    void solve();
    void win();
    void setHurt();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
